class MigrateAdminUserObject < ActiveRecord::Migration

  class << self
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # Data insert/delete methods
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def up
      init_roles
      add_acl_data
    end

    def down
      init_roles
      delete_acl_data
    end

    private
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      # Private data insert/delete methods
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
      def init_roles
        @@admin = Role.find(1)
      end

      def add_acl_data
        add_admin_user_object_data
      end

      def add_admin_user_object_data
        sobj = SystemObject.create(:name => "Admin User Access", :can_remove => false)
        @@admin.add_system_object(sobj) 

        SystemMethod.create(:name => "manage/folders/reset_menu", :system_object_id => sobj.id)
      end

      def delete_acl_data
        delete_admin_user_object_data
      end

      def delete_admin_user_object_data
        sobj = SystemObject.find(:first, :conditions => "name = 'Admin User Access'")
        @@admin.delete_system_object(sobj)
        sobj.destroy
      end
  end #class block
end
